class WashingMachine:
    height = 800  # 类属性

    def __init__(self, brand, type):  # 构造函数
        self.brand = brand  # 实例属性
        self.type = type  # 实例属性

    def washClothes(self):  # 实例方法，self代表对象本身
        print(f"{self.brand}:{self.type}会洗衣服")
        print("self is ", self)

    def setBrand(self, brand):
        self.brand = brand # 实例属性

    def getBrand(self):
        print("洗衣机的品牌是: ", self.brand)

    def __del__(self):
        print(f'{self.brand}:{self.type}被销毁了')


if __name__ == "__main__":
    # 查看类的属性
    print(WashingMachine.height)

    # 新增类的属性
    WashingMachine.width = 450
    print(WashingMachine.width)

    # 创建对象
    washing_machine_1 = WashingMachine("海尔", "滚筒")
    washing_machine_2 = WashingMachine("海信", "波轮")
    print(washing_machine_1)
    print(washing_machine_2)

    # 调用实例方法
    washing_machine_1.washClothes()
    washing_machine_2.washClothes()

    # 初始化实例属性
    washing_machine_1.setBrand("海尔1")
    washing_machine_2.setBrand("海信2")

    # 获取实例属性
    washing_machine_1.getBrand()
    print(washing_machine_1.brand)
    washing_machine_2.getBrand()
    print(washing_machine_2.brand)

    # 测试析构函数
    del washing_machine_1
    print("这是最后一行代码")